package com.dzzw.Servlet.VacationServlet;

import com.dzzw.Dao.VacationDao;
import com.dzzw.Model.Vacation;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

@WebServlet("/View/SelectVacationByEmployeeIdServlet")
public class SelectVacationByEmployeeIdServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    public SelectVacationByEmployeeIdServlet(){
        super();
    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        int employee_id = Integer.parseInt(request.getParameter("employee_id"));
        List<Vacation> list = VacationDao.SelectVacationByEmployeeId(employee_id);
        HttpSession session = request.getSession();
        session.setAttribute("SelectVacationByEmployeeId", list);
        request.getRequestDispatcher("/View/SelectVacationByEmployeeId.jsp").forward(request, response);
    }
}
